<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>社医堂</title>
<link rel="stylesheet" type="text/css" href="../../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/hui.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/iconfont.css" />
</head>
<body>


<style type="text/css">
.hui-speed-dial ul li{width:25%;}

/* 必要的css  */
.hui-news-list{width:92%;margin:6px 0px 0px 10px;padding:6px;background-color:#fff;}
.hui-news-list li{position:relative; width:100%; border-bottom:1px solid #E4E3E6; overflow:hidden;}
.hui-news-list li:last-child{border:none;}
.hui-news-list li a{display:block; overflow:hidden; padding:15px 0px;}
.hui-news-list div{-webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box; word-break:break-word;}
.hui-news-list-l{width:68%; float:left; line-height:1.6em; padding-right:10px; font-size:16px;}
.hui-news-list-l span{color:#999999; font-size:11px;}
.hui-news-list-r{width:32%; float:right;}
.hui-news-list-r img{width:100%;}
.hui-news-list-titile{line-height:1.6em; font-size:16px;}
.hui-news-list-imgs{font-size:0px; padding-top:8px;}
.hui-news-list-imgs img{display:block; width:33.3%; float:left; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box; word-break:break-word; padding-right:5px;}
.hui-news-list-img{font-size:0px; padding:8px 0px 5px 0px;}
.hui-news-list-img img{width:100%;}
.hui-news-list-info{color:#999999; font-size:11px; padding-top:8px; line-height:18px;}
.hui-speed-dial-text{line-height:20px;;}
.hui-speed-dial-icons img{width:40px;height:40px;border-radius:6px;;}
</style>


<div class="hui-wrap">
		
	<div class="hui-news-list">
		<ul id="list">				
	
		</ul>
	</div>
	
</div>


<script src="../../../script/hui.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../script/hui-tab.js" type="text/javascript"></script>
<script src="../../../script/api.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../script/stm.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
apiready = function() {

	islogin(1)
	
	$api.setStorage('curpage',1);
	list(1);
	api.setRefreshHeaderInfo({
		visible : true,
		bgColor : 'rgba(0,0,0,0)',
		textColor : '#666',
		textDown : '下拉刷新',
		textUp : '释放刷新'
	}, function(ret, err) {
		api.refreshHeaderLoadDone();
		list(1);
	});

	api.addEventListener({
	name:'scrolltobottom',
	extra:{
		threshold:0 //设置距离底部多少距离时触发，默认值为0，数字类型
	}
	
	}, function(ret, err){

	$api.setStorage('curpage',parseInt($api.getStorage('curpage'))+1)
	var page = parseInt($api.getStorage('curpage'));
	list(page);

	});


}

function list(page){

	var catid = api.pageParam.id
	var keyword = ''
	console.log("page="+page)


	api.ajax({
        url  : $api.getStorage('geturl')+'&c=ajaxmember&a=news',
        method: 'post',
        data: {
            values: { 
                catid  : catid,
				page   : page,
				keyword: keyword,
				type   : 2
            }
        }
    },function(res, err){

        if (res) {			
            if (res.status==1) {
				
				if(res.data.length<=0){
					api.toast({msg:'没有新数据了', location: 'bottom'})
					return false;
				} 
				
				//新闻资讯
				var list = ''
				for(i=0;i<res.data.length;i++){
					var thumb = res.data[i].thumb
					if(thumb==''){
						thumb = '../../../image/news/1.jpg'
					}else{
						thumb = $api.getStorage('weburl')+thumb
					}
					list += '<li><a href="javascript:(0);" onclick="toDetails(\'../video/\',\'details\','+res.data[i].id+');"><div class="hui-news-list-titile">'+res.data[i].title+'</div><div class="hui-news-list-img"><img src="'+thumb+'" /></div><div class="hui-news-list-info">'+jsDateDiff(res.data[i].addtime)+'</div></a></li>'		
				}
				if(page==1){
					hui("#list").html(list);
				}else{
					$api.append($api.byId("list"),list);
				}
				
            }else{
                api.toast({ msg:res.tip,location:'top' })
            }
        } else {
            alert( JSON.stringify( err ) );
        }
    }); 


}


</script>

</body>
</html>